home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Amiga-E / E_v3.2a / Src / Tools / AmigaLib / testinterrupts2.e < prev    next >
Text File  |  1995-04-04  |  798b  |  34 lines

  1. MODULE 'amigalib/interrupts',
  2.        'dos/dos',
  3.        'graphics/graphint'
  4.  
  5. DEF var
  6.  
  7. -> This example using an interrupt to toggle which string to print.
  8. -> Try running it in a Shell, then try redirecting output to a file.
  9. -> Look at the difference in the number of times it prints the same
  10. -> string (i.e., how many times it gets to complete a WriteF before
  11. -> the interrupt occurs),
  12. PROC main()
  13.   DEF i:isrvstr, strs:PTR TO LONG, x, y, z
  14.   strs:=['hello\n', 'goodbye\n']
  15.   var:=0
  16.   x:=0; y:=0
  17.   WriteF('var = \d\n', var)
  18.   addTOF(i, {test_int}, {var})
  19.   WriteF('var = \d\n', var)
  20.   REPEAT
  21.     z:=var
  22.     IF z<>y
  23.       x:=0; y:=z
  24.     ENDIF
  25.     WriteF('\d \s', x++, strs[z])
  26.   UNTIL CtrlC()
  27.   WriteF('var = \d\n', var)
  28.   remTOF(i)
  29. ENDPROC
  30.  
  31. PROC test_int(addr:PTR TO LONG)
  32.   addr[]:=1-addr[]
  33. ENDPROC
  34.